class MyCircularQueue {
    int *a;
    int front, rear;
    int capacity;
public:
    MyCircularQueue(int k):front(0), rear(0), capacity(k+1) {
        a = (int*)malloc(sizeof(int)*capacity);
    }
    
    bool enQueue(int value) {
        if(isFull()) return false;
        int t = rear;
        rear=(rear+1)%capacity;
        a[t] = value;
        return true;
    }
    
    bool deQueue() {
        if(isEmpty()) return false;
        else {
            int t = front;
            front = (front+1)%capacity;
            return true;
        }
    }
    
    int Front() {
        if(isEmpty())return -1;
        return a[front];
    }
    
    int Rear() {
        if(isEmpty())return -1;
        int t = (rear+capacity-1)%capacity;
        return a[t];
    }
    
    bool isEmpty() {
        return front==rear;
    }
    
    bool isFull() {
        return front==(rear+1)%capacity;
    }
};

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * MyCircularQueue* obj = new MyCircularQueue(k);
 * bool param_1 = obj->enQueue(value);
 * bool param_2 = obj->deQueue();
 * int param_3 = obj->Front();
 * int param_4 = obj->Rear();
 * bool param_5 = obj->isEmpty();
 * bool param_6 = obj->isFull();
 */

